import java.util.ArrayList;
import java.util.List;

class Person {
    public String name;
    public Integer age;

    public void talk() {
        System.out.println("My name is:" + name+",old is:" + age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}

class Solution1 {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        List<Integer> list = new ArrayList<>();
        list.add(nums[0]);
        for(int i = 1; i<n; i++) {
            if(nums[i] > list.get(list.size()-1)) {
                list.add(nums[i]);
            }else {
                int left = 0, right = list.size()-1;
                while(left < right) {
                    int mid = left + (right - left)/2;
                    if(list.get(mid) < nums[i]) {
                        left = mid + 1;
                    }else {
                        right = mid;
                    }
                }
                list.set(left, nums[i]);
            }
            System.out.println(list);
        }
        System.out.println(list);
        return list.size() >= 3;
    }
}

class Solution2 {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        for(int i = 0; i<n; i++) {
            dp[i] = 1;
        }
        int ret = 0;
        for(int i = 1; i<n; i++) {
            for(int j =0 ; j<i; j++) {
                if(nums[j] < nums[i]) {
                    dp[i] = Math.max(dp[i], dp[j]+1);
                }
            }
            ret = Math.max(ret, dp[i]);
        }
        return ret >= 3;
    }
}

class Solution3 {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        int a = nums[0];
        int b = Integer.MAX_VALUE;
        for(int i = 1; i<n; i++) {
            if(nums[i] > b) return true;
            if(nums[i] < a) {
                a = nums[i];
            }else if(nums[i] > a){
                b = nums[i];
            }
        }
        return false;
    }
}

class Solution4 {
    public int findLengthOfLCIS(int[] nums) {
        int n = nums.length;
        int ret = 0;
        int count = 0;
        for(int i = 1; i<n; i++) {
            if(nums[i] > nums[i-1]) {
                count++;
            }else {
                count = 0;
            }
            ret = Math.max(ret, count);
        }
        return ret;
    }
}

class Solution5 {
    public int maxProfit(int[] prices) {
        int n = prices.length;
        int ret = 0;
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<n; j++) {
                ret = Math.max(ret, prices[j] - prices[i]);
            }
        }
        return ret;
    }
}

class Solution {
    public int maxProfit(int[] prices) {
        int n = prices.length;
        int min = Integer.MAX_VALUE;
        int ret = 0;
        for(int i = 0; i<n; i++) {
            if(prices[i] > min) min = prices[i];
            ret = Math.max(ret, prices[i] - min);
        }
        return ret;
    }
}

public class  Test {
    public static void main(String[] args) {
        Person p = new Person();
        p.setName("Tom");
        p.setAge(18);
        p.talk();
    }
}